package fun.codefarmer.pm.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @ ClassName WebConfig
 * @ Descriotion TODO
 * @ author  codeFarmer_z
 * @ 公众号：码农教程
 * @ Date 2022/5/11 20:39
 **/
public class WebConfig implements WebMvcConfigurer {
    @Value("${web.profile}")
    private String path;
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry)
    {
        String os = System.getProperty("os.name");
        /** 本地文件上传路径 */
        if (os.toLowerCase().startsWith("win")) {
            registry.addResourceHandler("/profile" + "/**")
                    .addResourceLocations("file:" + path + "/");
        } else {
            registry.addResourceHandler("/profile" + "/**")
                    .addResourceLocations("file:" + path + "/");
        }

    }
}
